<?php

require_once('Myzen/Oauth/Signaturemethod.php');

class Myzen_Oauth_Signaturemethod_HMACSHA1 extends Myzen_Oauth_Signaturemethod {
  function get_name() {
    return "HMAC-SHA1";
  }

  public function build_signature($request, $consumer, $token) {
    $base_string = $request->get_signature_base_string();
    $request->base_string = $base_string;

    $key_parts = array(
      $consumer->secret,
      ($token) ? $token->secret : ""
    );

    $key_parts = Myzen_Oauth_Util::urlencode_rfc3986($key_parts);
    $key = implode('&', $key_parts);

Zend_Registry::get('dt_log')->log('signature built from'.$base_string.'-'.$key,7);
Zend_Registry::get('dt_log')->log('signature:'.base64_encode(hash_hmac('sha1', $base_string, $key, true)),7);
    return base64_encode(hash_hmac('sha1', $base_string, $key, true));
  }
}